/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package deque;

import exceptions.EmptyDequeException;
import exceptions.EmptyStackException;
import stack.Stack;

/**
 *
 * @author pc
 */
public class DequeStack<E> implements Stack<E> {

    private Deque<E> D;

    public DequeStack() {
        D = new MyDeque();
    }

    public int size() {
        return D.size();
    }
    
    public boolean isEmpty() {
        return D.isEmpty();
    }

    public void push(E e) {
        D.addLast(e);
    }

    public E top() throws EmptyStackException {
        try {
            return D.getLast();
        } catch (EmptyDequeException e) {
            throw new EmptyStackException("Stack vuoto!");
        }
    }

    @Override
    public E pop() throws EmptyStackException {
       return D.removeLast();
    }
}